type surface =
    Empty
  | Img of Sdlvideo.surface

class imData =
object (self)
  val mutable file = ""
  val mutable dims = (0,0)
  val mutable original:surface = Empty
  val mutable current:surface = Empty
  val layer = Array.make 3 (Empty)
  val mutable grey = false
  val mutable grid = false
(* Methods *)
  method filename = file
  method dims = dims
  method original = match original with |
      Empty -> Sdlvideo.get_video_surface ()
    |Img i -> i
  method current = match current with |
      Empty -> Sdlvideo.get_video_surface ()
    |Img i -> i
  method set_current i = current <- Img i
  method toggle_grey = function () -> grey <- not grey
  method toggle_grid = function () -> grid <- not grid
  method grey = grey
  method grid = grid
  method isInit = function () -> not (file = "")
  method load = function
  None -> ()
    | Some e ->
      try
	begin
	  original <- Img (Sdlloader.load_image e);
	  current <- Img (Sdlloader.load_image e);
	  file<- e;
	  dims <- ((Sdlvideo.surface_info self#original).Sdlvideo.w, (Sdlvideo.surface_info self#original).Sdlvideo.h)
	end with
	    Sdlloader.SDLloader_exception _ ->
	      begin
		()(*"The file doesn't exist or cannot be opened."*)
	      end		
end
